<template>
  <f7-page @page:reinit="getDataItems">
    <f7-navbar title="吉林动画学院用章申请表" back-link="Back"></f7-navbar>

    <f7-list inline-labels no-hairlines-md>
      <f7-list-item>
        <f7-label>名称</f7-label>
        <f7-input type="text" :value="formContent.title"  :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item  >
        <f7-label>申请部门</f7-label>
        <f7-input type="text"   :value="formContent.orgName" :disabled="true" >   </f7-input>
      </f7-list-item>
      <f7-list-item  >
        <f7-label>用印数</f7-label>
        <f7-input  type="tel"  :value="formContent.usageCount" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>印章类别</f7-label>
        <f7-input type="select"  :value="formContent.sealType" :disabled="true">
          <option v-for="(value, index) in sealNum" v-bind:key="index" v-bind:value="index">{{value}}</option>
        </f7-input>
      </f7-list-item>
      <f7-list-item  >
        <f7-label>申请日期</f7-label>
        <f7-input type="text"   :value="formContent.creationDate" :disabled="true" >   </f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>备注</f7-label>
        <f7-input type="textarea"   :value="formContent.remark" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>部门负责人</f7-label>
        <f7-input type="text"   :value="formContent.departmentHead" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>分公司负责人</f7-label>
        <f7-input type="text"   :value="formContent.filialeHead" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>法律顾问</f7-label>
        <f7-input type="text"   :value="formContent.counsel" :disabled="true"></f7-input>
      </f7-list-item>

      <f7-list-item >
        <f7-label>总经理</f7-label>
        <f7-input type="text"   :value="formContent.generalManager" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>印章专管员</f7-label>
        <f7-input type="text"   :value="formContent.sealAdministrator" :disabled="true"></f7-input>
      </f7-list-item>
      <f7-list-item >
        <f7-label>经办人</f7-label>
        <f7-input type="text"   :value="formContent.createBy" :disabled="true"></f7-input>
      </f7-list-item>
    </f7-list>

    <f7-list accordion >
      <f7-list-item title="流程历史" v-bind:link="'/oa/activities/' + formContent.processInstanceId"></f7-list-item>
      <f7-list-item title="附件数据" v-bind:link="'/oa/attachments/' + formContent.id"></f7-list-item>
      <f7-list-item accordion-item  id="m2"  :accordion-item-opened="true" title="业务审批" v-show="paramsId ==-1 ? false : true">
        <f7-accordion-content>
          <f7-block>
            <f7-list inline-labels no-hairlines-md>
              <f7-list-item>
                <f7-input type="textarea" placeholder="请在这里填写批注" v-bind:value="admitData.comment"  @input="admitData.comment =  $event.target.value"></f7-input>
              </f7-list-item>
              <f7-list-item>
                <img slot="media" v-bind:src="admitData.signature" />
              </f7-list-item>
            </f7-list>
            <f7-button raised href="/oa/personalwork/signature" >手写签名</f7-button>
            <f7-block strong>
              <f7-row>
                <f7-col width="50">
                  <f7-button fill raised @click="superiorDecision('同意')">同意</f7-button>
                </f7-col>
                <f7-col width="50">
                  <f7-button fill raised color="red" @click="superiorDecision('不同意')">不同意</f7-button>
                </f7-col>
              </f7-row>
            </f7-block>
          </f7-block>
        </f7-accordion-content>
      </f7-list-item>

    </f7-list>
  </f7-page>
</template>

<script>
    export default {
      name: "admitSeal",
      data() {
        return {
          formContent: { },
          admitData: {
            accepted: "不同意",
            signature:"",
            comment: "",
            taskId: 0,
          },
          paramsEntityId: this.$f7route.params.entityId,
          paramsId: this.$f7route.params.id,
          sealNum: this.GLOBAL.sealNum,
        }
      },
      created() {
        this.$f7ready((f7) => {
          let that = this;
          f7.request.setup({
            headers: {
              'AccessToken': sessionStorage.getItem('accessToken'),
              'JSESSIONID': sessionStorage.getItem('userToken'),
            }
          });
          f7.request.json(that.GLOBAL.RequestAddress + '/camel/rest/sealapplys/' +  that.paramsEntityId, { }, function (result) {
            that.formContent = result;
          })
        });
      },
      methods: {
        getDataItems: function () {
          let that = this;
          let app = that.$f7;
          let url = that.GLOBAL.RequestAddress + '/camel/rest/sealapplys/' + that.paramsEntityId;
          app.request.json(url, {}, function (result) {
            that.formContent = result;
          })
          that.showSignaure();
        },
        superiorDecision: function (opinion) {
          let that = this;
          let app = that.$f7
          let url = that.GLOBAL.RequestAddress + "/camel/rest/sealapplys/workflow/completeTask"
          that.admitData.taskId = that.paramsId;
          that.admitData.accepted = opinion;
          //console.log(opinion)
          app.request.json(url, that.admitData, function (result) {
            that.showAlert("提示", result.msg);
          })
        },
        showAlert: function (title, text) {
          let that = this;
          let app = that.$f7
          app.dialog.alert(text, title, () => {
            that.$f7router.back();
          });
        },
        showSignaure : function () {
          let that = this;
          that.admitData.signature = that.$f7.data.admitSig;
          that.$f7.data.admitSig = "";
        },
      },
    }
</script>

<style scoped>

</style>
